package com.kystar.muxplayer.selfview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.TextView;
import com.kystar.muxplayer.BaseApp;
import com.kystar.muxplayer.R;
import com.kystar.muxplayer.base.TLog;
import com.kystar.muxplayer.model.Bound;
import com.kystar.muxplayer.model.Layer;

public class PvmLayerView extends View {

    private Layer mLayer;
    Paint bourderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    float strokeWidth = 0.5f;
    public PvmLayerView(Context context) {
        super(context);
    }

    public PvmLayerView(Context context,
        @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }



    public PvmLayerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public PvmLayerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
        int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    private void init() {
//        setTextColor(getResources().getColor(R.color.main_font_color_normal));
        bourderPaint.setStyle(Paint.Style.STROKE);//空心矩形框
        bourderPaint.setStrokeWidth(strokeWidth);
        if (isSelected()) {
            bourderPaint.setColor(Color.RED);
        } else {
            bourderPaint.setColor(Color.YELLOW);
        }
    }

    @Override
    public void setSelected(boolean selected) {
        super.setSelected(selected);
        if (selected) {
            bourderPaint.setColor(Color.RED);
        } else {
            bourderPaint.setColor(Color.YELLOW);
        }
        invalidate();
    }

    public void setLayer(Layer layer,int frameWidth,int frameHeight) {


    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        invalidate();
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
//        if (getVisibility() != VISIBLE) return;

        canvas.drawRect(0,0,getWidth(),getHeight(),bourderPaint);
    }
}
